import {
  getOrderList,
  getRefundList,
  postOrder,
  putOrder,
  putRefundApprove,
  putRefundRefuse,
  putRefundShouHuo,
  putRefundYanhuo,
  putOrderFh,
  putOrderCancel,
  putOrderRefundConfirm,
  deleteOrder,
  getMapList,
  postMap,
  putMap,
  deleteMap
} from '@/api/order'
import {
  getToken,
  setToken,
  removeToken
} from '@/utils/auth'
import {
  resetRouter
} from '@/router'

const getDefaultState = () => {
}

const state = getDefaultState()

const mutations = {}

const actions = {
  getOrderList({
    commit
  }, data) {
    return new Promise((resolve, reject) => {
      getOrderList(data).then(response => {
        resolve(response)
      }).catch(error => {
        console.log(error)
        reject(error)
      })
    })
  },
  getRefundList({
    commit
  }, data) {
    return new Promise((resolve, reject) => {
      getRefundList(data).then(response => {
        resolve(response)
      }).catch(error => {
        console.log(error)
        reject(error)
      })
    })
  },
  postOrder({
    commit
  }, data) {
    return new Promise((resolve, reject) => {
      postOrder(data).then(response => {
        resolve(response)
      }).catch(error => {
        console.log(error)
        reject(error)
      })
    })
  },
  putOrder({
    commit
  }, data) {
    return new Promise((resolve, reject) => {
      putOrder(data).then(response => {
        resolve(response)
      }).catch(error => {
        console.log(error)
        reject(error)
      })
    })
  },
  putOrderFh({
    commit
  }, data) {
    return new Promise((resolve, reject) => {
      putOrderFh(data).then(response => {
        resolve(response)
      }).catch(error => {
        console.log(error)
        reject(error)
      })
    })
  },
  putRefundApprove({
    commit
  }, data) {
    return new Promise((resolve, reject) => {
      putRefundApprove(data).then(response => {
        resolve(response)
      }).catch(error => {
        console.log(error)
        reject(error)
      })
    })
  },
  putRefundRefuse({
    commit
  }, data) {
    return new Promise((resolve, reject) => {
      putRefundRefuse(data).then(response => {
        resolve(response)
      }).catch(error => {
        console.log(error)
        reject(error)
      })
    })
  },
  putRefundShouHuo({
    commit
  }, data) {
    return new Promise((resolve, reject) => {
      putRefundShouHuo(data).then(response => {
        resolve(response)
      }).catch(error => {
        console.log(error)
        reject(error)
      })
    })
  },
  putRefundYanhuo({
    commit
  }, data) {
    return new Promise((resolve, reject) => {
      putRefundYanhuo(data).then(response => {
        resolve(response)
      }).catch(error => {
        console.log(error)
        reject(error)
      })
    })
  },
  putOrderCancel({
    commit
  }, data) {
    return new Promise((resolve, reject) => {
      putOrderCancel(data).then(response => {
        resolve(response)
      }).catch(error => {
        console.log(error)
        reject(error)
      })
    })
  },
  putOrderRefundConfirm({
    commit
  }, data) {
    return new Promise((resolve, reject) => {
      putOrderRefundConfirm(data).then(response => {
        resolve(response)
      }).catch(error => {
        console.log(error)
        reject(error)
      })
    })
  },
  deleteOrder({
    commit
  }, data) {
    return new Promise((resolve, reject) => {
      deleteOrder(data).then(response => {
        resolve(response)
      }).catch(error => {
        console.log(error)
        reject(error)
      })
    })
  },
  getMapList({
    commit
  }, data) {
    return new Promise((resolve, reject) => {
      getMapList(data).then(response => {
        resolve(response)
      }).catch(error => {
        console.log(error)
        reject(error)
      })
    })
  },
  postMap({
    commit
  }, data) {
    return new Promise((resolve, reject) => {
      postMap(data).then(response => {
        resolve(response)
      }).catch(error => {
        console.log(error)
        reject(error)
      })
    })
  },
  putMap({
    commit
  }, data) {
    return new Promise((resolve, reject) => {
      putMap(data).then(response => {
        resolve(response)
      }).catch(error => {
        console.log(error)
        reject(error)
      })
    })
  },
  deleteMap({
    commit
  }, data) {
    return new Promise((resolve, reject) => {
      deleteMap(data).then(response => {
        resolve(response)
      }).catch(error => {
        console.log(error)
        reject(error)
      })
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
